package FlyweightPattern;


import java.util.HashMap;
import java.util.Map;

public class ShapeFactory {
    private static Map<String, Shape> circleMap = new HashMap<String, Shape>();
    public Shape getCircle(String color){
        if(circleMap.containsKey(color)){
            System.out.println(color+" circle exist, return");
            return circleMap.get(color);
        }
        System.out.println(color+" circle not exist, now new a Circle");
        Circle circle = new Circle(color);
        circleMap.put(color, circle);
        return circle;
    }
}
